import redis
import uuid

# POOL = redis.ConnectionPool(host="146.56.197.217", port=6379, decode_responses=True, max_connections=10)
# POOL = redis.ConnectionPool(host="192.168.19.130", port=6379, decode_responses=True, max_connections=10)
POOL = redis.ConnectionPool(host="146.56.197.217",password='wejimaxifalu', port=6379, decode_responses=True, max_connections=10)
conn = redis.Redis(connection_pool=POOL)

# key = "6b41d41e-d3e4-45b4-aacc-f16bea50be02"
# data = r.get(key)
# # r.delete(key)
# print(data)

# aa = ['backup3', 'backup4', 'backup2', 'backup1']
# keys = conn.keys("*")
# print(1111,conn.keys("*"))
# for key in keys:
#     print(f"{key}:{conn.get(key)}")
#     # conn.delete(key)

# access_token = uuid.uuid4()
# # conn.set(str(token), user_obj.id, ex=10) # ex=10 过期时间20S
# conn.set(str(access_token), 3)  # nx=True:key不存在时才写入
